<?php

class Model_Config extends Joob_Db_Table	{
	
	protected $key = "id";
	
	protected $db = "config";
	
	public static function getConfig(){
		$config = new Model_Config();
		$config = $config->search('','intro, contact, agent_info, footer',1,'id DESC');
		return array('intro'=>$config[0]->intro,'contact'=>$config[0]->contact,
				'agent_info'=>$config[0]->agent_info, 'footer'=>$config[0]->footer
				);
	}
	
	public static function getAbout(){
		$config = new Model_Config();
		$config = $config->search('','intro',1,'id DESC');
		if(count($config)>0)
		return $config[0]->intro;
	}
	
	public static function getAgentInfo(){
		$config = new Model_Config();
		$config = $config->search('','agent_info',1,'id DESC');
		if(count($config)>0)
		return $config[0]->agent_info;
	}
	
	public static function getContact(){
		$config = new Model_Config();
		$config = $config->search('','contact',1,'id DESC');
		if(count($config)>0)
		return $config[0]->contact;
	}
	
	public static function getFooter(){
		$config = new Model_Config();
		$config = $config->search('','footer',1,'id DESC');
		if(count($config)>0)
		return $config[0]->footer;
	}
	
	public function updateConfig(){
		return $this->edit('intro, contact, agent_info, footer');
	}
	
}

?>